﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace memcached.Tx
{
    internal interface ITxCacheOperation
    {
        /// <summary>
        /// Identifier, for messages.
        /// </summary>
        string Name { get; }

        /// <summary>
        /// Perform the action virtually. Execution phase.
        /// </summary>
        /// <returns>any result of the operation to be passed to operation caller</returns>
        object Execute();

        /// <summary>
        /// Make any permament changes. Commit phase.
        /// </summary>
        /// <returns>if succeeded; false will abort transaction and cause Rollback</returns>
        bool Persist();

        /// <summary>
        /// Undo permanent action taken.
        /// </summary>
        /// <returns>if succeeded; false will abort transaction with inconsistent state</returns>
        bool Rollback();
    }
}